<?php

class Service_Form_Customer extends Custom_Form
{

	function  __construct() {
		parent::__construct(null);
	}

	public function init()
    {
        $translate = Zend_Registry::get('translate');
		$this->setTranslator($translate);

        $objDistrict = new Service_Model_DbTable_District();
		$this->setName("customer");
        $this->setMethod('post');

		$this->addElement('text', 'first_name', array(
            'filters'    => array('StringTrim'),
            'validators' => array(
                array('StringLength', false, array(0, 50)),
				array('Alnum'),
			),

            'required'   => true,
            'label'      => __('First Name').':',
        ));

		$this->addElement('text', 'last_name', array(
            'filters'    => array('StringTrim'),
            'validators' => array(
                array('StringLength', false, array(0, 50)),
				array('Alnum'),
            ),
            'required'   => true,
            'label'      => __('Last Name').':',
        ));

        $this->addElement('text', 'contact_no', array(
            'filters'    => array('StringTrim'),
            'validators' => array(
                array('StringLength', false, array(0, 50)),
		    ),
            'required'   => true,
            'label'      => __('Contact No.').':',
        ));
        
        $this->addElement('textarea', 'permanent_address', array(
            'filters'    => array('StringTrim'),
            'validators' => array(
                array('StringLength', false, array(0, 255)),
		    ),
            'required'   => true,
            'rows'       => 3,
            'cols'       => 50,
            'label'      => __('Permanent Address').':',
        ));

        $this->addElement('textarea', 'current_address', array(
            'filters'    => array('StringTrim'),
            'validators' => array(
                array('StringLength', false, array(0, 255)),
		    ),
            'required'   => true,
            'rows'       => 3,
            'cols'       => 50,
            'label'      => __('Current Address').':',
        ));

        $this->addElement('text', 'citizenship_no', array(
            'filters'    => array('StringTrim'),
            'validators' => array(
                array('StringLength', false, array(0, 50)),
		    ),
            'required'   => true,
            'label'      => __('Citizenship No').':',
        ));

        $this->addElement('select', 'citizenship_district_id', array(
            'label'      => __('District of Citizenship').':',
            'multiOptions' => $objDistrict->getOptions(),
		));

        $this->addElement('text', 'passport_no', array(
            'filters'    => array('StringTrim'),
            'validators' => array(
                array('StringLength', false, array(0, 50)),
		    ),
            'label'      => __('Passport No').':',
        ));

        $this->addElement('file', 'image', array(
            'label'      => __('Select Image').':',
			'decorators' => $this->setCustomFileDecorators(),
		));

        $config   = Zend_Registry::get('config');
        $filePath = PUBLIC_PATH. DS .$config->params->customer->imagePath;
        $size     = $config->params->upload->imageSize * 1024 * 1024;

        $this->image->setDestination($filePath);
        $this->image->addValidator('Size', false, $size);
        $this->image->addValidator('Extension', false, 'jpg,png,gif');

       	$this->addElement('submit', 'save', array(
            'required' => false,
            'ignore'   => true,
            'label'    => __('Save'),
        ));
        
		$this->save->removeDecorator('label');
	}
}